﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace iReaper.IndexService.WebTools.WWESource
{
    public class MSAwareWebClient : CookieAwareWebClient
    {
        // Fields
        private WWEIdentity _identity;

        // Methods
        public MSAwareWebClient(string username, string password)
        {
            this._identity = new WWEIdentity(username, password);
            this._identity.Logon();
        }

        protected override WebResponse GetWebResponse(WebRequest request)
        {
            WebResponse response = base.GetWebResponse(request);
            if (!this._identity.VerifyCookie())
            {
                response = base.GetWebResponse(request);
            }
            return response;
        }

        // Properties
        public override CookieContainer Cookies
        {
            get
            {
                return this._identity.Cookie;
            }
            set
            {
                throw new NotImplementedException();
            }
        }
    }
}
